﻿using NfsBLL;
using NfsCommon.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MobileWeb.Controllers
{
    public class PasswordController : Controller
    {
        //
        // GET: /Password/
        public ActionResult Index()
        {
            return View();
        }

        #region 修改密码
        public JsonResult UptPassword(string pwd)
        {
            int id = int.Parse(CookieHelper.GetDecodeCookie("nfs_UserId"));
            AccountBLL bll = new AccountBLL();
            bool flag = bll.UptPassword(id, pwd);
            if (flag == true)
            {
                return Json(flag, JsonRequestBehavior.AllowGet);
            }
            return Json("error", JsonRequestBehavior.AllowGet);
        }

        #endregion

        #region 查询修改密码时输入的旧密码是否与数据库的相匹配
        [HttpPost]
        public JsonResult GetPassword(string pwd)
        {
            int id = int.Parse(CookieHelper.GetDecodeCookie("nfs_UserId"));
            AccountBLL bll = new AccountBLL();
            bool flag = bll.GetPassword(id, pwd);
            if (flag == true)
            {
                return Json(flag, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return Json("", JsonRequestBehavior.AllowGet);
            }
        }
        #endregion

    }
}
